/*
 * Copyright (C) 2021 Baidu, Inc. All Rights Reserved.
 */
package com.chukun.rpc.protocol.handler;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * <p>请求处理器业务线程池<p/>
 *
 * @author chukun
 * @version 1.0
 * @since 1.0-SNAPSHOT
 */
public class TinyRpcRequestProcessor {

    private static ThreadPoolExecutor requestPoolExecutor;

    private TinyRpcRequestProcessor() {}

    static {
        requestPoolExecutor = new ThreadPoolExecutor(10, 10, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(5000));
    }



    public  void submitRequest(Runnable r) {
        requestPoolExecutor.submit(r);
    }

    private static class TinyRpcRequestProcessorHolder {
        private static final TinyRpcRequestProcessor INSTANCE = new TinyRpcRequestProcessor();
    }

    public static TinyRpcRequestProcessor getInstance() {
        return TinyRpcRequestProcessorHolder.INSTANCE;
    }

}
